//
//  WBVisitorTableViewController.swift
//  weibo
//
//  Created by yanghong on 15/12/6.
//  Copyright © 2015年 杨鸿. All rights reserved.
//

import UIKit

class WBVisitorTableViewController: UITableViewController {
    
    // 用户是否登录的标记
    var isUserLogin = WBUserAccountViewModel.sharedAccount.accessToken != nil
    
   // var isUserLogin = true
    
    var visitorView: WBVisitorView?
    
    override func loadView() {
        
        if isUserLogin {
        
            super.loadView()
        }else {
        
        setupVisitorView()
        
        }
    }
    
  private  func setupVisitorView() {
    //加载 VisitorView视图
    visitorView = WBVisitorView()
    
     visitorView!.registerButton.addTarget(self, action: "login", forControlEvents: .TouchUpInside)
    visitorView?.loginBuuton.addTarget(self, action: "login", forControlEvents: .TouchUpInside)
    
    
    navigationItem.leftBarButtonItem = UIBarButtonItem( title: "注册", target: self, action: "login")
    navigationItem.rightBarButtonItem = UIBarButtonItem( title: "登录", target: self, action: "login")
    
        
     view = visitorView
    
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    func login() {
        
        let oauthVc = WBOAuthViewController()
        
        navigationController?.presentViewController(WBNavigationController(rootViewController: oauthVc), animated: true, completion: nil)
    
     print("modal一个登录或者注册页面")
    
    }

}
